package com.example.websocket.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

import com.example.websocket.message.brow.WiselyMessage;
import com.example.websocket.message.server.WiselyResponse;

@Controller
public class SendMessageContrller {
		
	@MessageMapping("/welcome")//1
	@SendTo("/topic/getResponse")  //2
	public WiselyResponse say(WiselyMessage message) throws Exception{
				Thread.sleep(3000);
				System.out.println(message.getName());
				return new WiselyResponse("Welcome,"+message.getName()+"!");
	}
	
	// 1 当浏览器向服务端发送请求，@MessageMapping映射。welcome 这个地址 ，类似 @RequestMapping
	// 2 当服务端有消息时，会对订阅了@SendTo 中的路劲的浏览器发送消息
}


